26IM

Technical details

Show code
library(GeoPressureR)
library(leaflet)
library(leaflet.extras)
library(raster)
library(dplyr)
library(ggplot2)
library(kableExtra)
library(plotly)
library(GeoLocTools)
setupGeolocation()
knitr::opts_chunk$set(echo = FALSE)
load(paste0("../data/1_pressure/", params$gdl_id, "_pressure_prob.Rdata"))
load(paste0("../data/2_light/", params$gdl_id, "_light_prob.Rdata"))
load(paste0("../data/3_static/", params$gdl_id, "_static_prob.Rdata"))
load(paste0("../data/4_basic_graph/", params$gdl_id, "_basic_graph.Rdata"))

Settings used

All the results produced here are generated with (1) the raw geolocator data, (2) the labeled files of pressure and light and (3) the parameters listed below.

Show code
kable(gpr) %>% scroll_box(width = "100%")
gdl_id crop_start crop_end thr_dur extent_N extent_W extent_S extent_E map_scale map_max_sample map_margin prob_map_s prob_map_s_calib prob_map_thr shift_k kernel_adjust calib_lon calib_lat calib_1_start calib_1_end calib_2_start calib_2_end calib_2_lon calib_2_lat prob_light_w thr_prob_percentile thr_gs RingNo scientific_name common_name mass wing_span Color
26IM 2020-07-14 2021-05-28 24 51 -18 4 16 5 300 30 1 2 0.9 0 1.4 8.705503 46.55076 2020-07-14 2020-09-17 2021-05-03 2021-05-28 NA NA 0.1 0.9 120 N643042 Oenanthe oenanthe Northern wheatear NA NA NA

Pressure timeserie

The labeling of pressure data is illustrated with this figure. The black dots indicates the pressure datapoint not considered in the matching. Each stationary period is illustrated by a different colored line.

Show code
pressure_na <- pam$pressure %>%
  mutate(obs = ifelse(isoutliar | sta_id == 0, NA, obs))
p <- ggplot() +
  geom_line(data = pam$pressure, aes(x = date, y = obs), colour = "grey") +
  geom_point(data = subset(pam$pressure, isoutliar), aes(x = date, y = obs), colour = "black") +
  # geom_line(data = pressure_na, aes(x = date, y = obs, color = factor(sta_id)), size = 0.5) +
  geom_line(data = do.call("rbind", shortest_path_timeserie) %>% filter(sta_id > 0), aes(x = date, y = pressure0, col = factor(sta_id))) +
  theme_bw() +
  scale_colour_manual(values = col) +
  scale_y_continuous(name = "Pressure(hPa)")

ggplotly(p, dynamicTicks = T) %>% layout(showlegend = F)

Light

Show code
raw_geolight <- pam$light %>%
  transmute(
    Date = date,
    Light = obs
  )
lightImage(tagdata = raw_geolight, offset = 0)
tsimagePoints(twl$twilight,
  offset = 0, pch = 16, cex = 1.2,
  col = ifelse(twl$deleted, "grey20", ifelse(twl$rise, "firebrick", "cornflowerblue"))
)
abline(v = gpr$calib_2_start, lty = 1, col = "firebrick", lwd = 1.5)
abline(v = gpr$calib_1_start, lty = 1, col = "firebrick", lwd = 1.5)
abline(v = gpr$calib_2_end, lty = 2, col = "firebrick", lwd = 1.5)
abline(v = gpr$calib_1_end, lty = 2, col = "firebrick", lwd = 1.5)

Show code
hist(z, freq = F)
lines(fit_z, col = "red")

The probability map resulting from light data alone can be seen below.

Show code
li_s <- list()
l <- leaflet(width = "100%") %>%
  addProviderTiles(providers$Stamen.TerrainBackground) %>%
  addFullscreenControl()
for (i_r in seq_len(length(light_prob))) {
  i_s <- metadata(light_prob[[i_r]])$sta_id
  info <- pam$sta[pam$sta$sta_id == i_s, ]
  info_str <- paste0(i_s, " | ", info$start, "->", info$end)
  li_s <- append(li_s, info_str)
  l <- l %>% addRasterImage(light_prob[[i_r]], opacity = 0.8, colors = "OrRd", group = info_str)
}
l %>%
  addCircles(lng = gpr$calib_lon, lat = gpr$calib_lat, color = "black", opacity = 1) %>%
  addLayersControl(
    overlayGroups = li_s,
    options = layersControlOptions(collapsed = FALSE)
  ) %>%
  hideGroup(tail(li_s, length(li_s) - 1))

Light vs Pressure

We can compare light and pressure location at long stationary stopover (>5 days). By assuming the best match of the pressure to be the truth, we can plot the histogram of the zenith angle and compare to the fit of kernel density at the calibration site.

Show code
 raw_geolight <- pam$light %>%
    transmute(
      Date = date,
      Light = obs
    )
 dur <- unlist(lapply(static_prob_marginal, function(x) difftime(metadata(x)$temporal_extent[2],metadata(x)$temporal_extent[1], units = "days" )))
  long_id <- which(dur>5 & seq(1,length(dur))<=length(shortest_path_timeserie))

  par(mfrow = c(2, 3))
  for (i_s in long_id){
    twl_fl <- twl %>%
      filter(!deleted) %>%
      filter(twilight>shortest_path_timeserie[[i_s]]$date[1] & twilight<tail(shortest_path_timeserie[[i_s]]$date,1))
    sun <-  solar(twl_fl$twilight)
    z_i <- refracted(zenith(sun, shortest_path_timeserie[[i_s]]$lon[1], shortest_path_timeserie[[i_s]]$lat[1]))
    hist(z_i, freq = F, main = paste0("sta_id=",i_s, " | ",nrow(twl_fl),"twls"))
    lines(fit_z, col = "red")
    xlab("Zenith angle")
  }

Similarly, we can plot the line of sunrise/sunset at the best match of pressure (yellow line) and compare to the raw and labeled light data.

Show code
  lightImage(
    tagdata = raw_geolight,
    offset = gpr$shift_k / 60 / 60
  )
  tsimagePoints(twl$twilight,
                offset = gpr$shift_k / 60 / 60, pch = 16, cex = 1.2,
                col = ifelse(twl$deleted, "grey20", ifelse(twl$rise, "firebrick", "cornflowerblue"))
  )
  for (ts in shortest_path_timeserie){
    if (!is.null(ts)){
    twl_fl <- twl %>%
      filter(twilight>ts$date[1] & twilight<tail(ts$date,1))
    if (nrow(twl_fl)>0){
    tsimageDeploymentLines(twl_fl$twilight,
                           lon = ts$lon[1], ts$lat[1],
                           offset = gpr$shift_k / 60 / 60, lwd = 3,col = adjustcolor("orange", alpha.f = 0.5))
    }
    }
  }

GeoPressureViz

To visualize the path on GeoPressureViz, you will need to also load the pressure and light probability map and align them first with the code below.

Show code
sta_marginal <- unlist(lapply(static_prob_marginal, function(x) raster::metadata(x)$sta_id))
sta_pres <- unlist(lapply(pressure_prob, function(x) raster::metadata(x)$sta_id))
sta_light <- unlist(lapply(light_prob, function(x) raster::metadata(x)$sta_id))
pressure_prob <- pressure_prob[sta_pres %in% sta_marginal]
light_prob <- light_prob[sta_light %in% sta_marginal]

The code below will open with the shortest path computed with the graph approach.

Show code
geopressureviz <- list(
  pam_data = pam,
  static_prob = static_prob,
  static_prob_marginal = static_prob_marginal,
  pressure_prob = pressure_prob,
  light_prob = light_prob,
  pressure_timeserie = shortest_path_timeserie
)
save(geopressureviz, file = "~/geopressureviz.RData")

shiny::runApp(system.file("geopressureviz", package = "GeoPressureR"),
  launch.browser = getOption("browser")
)

Stationay period information

Show code
pam$sta %>% kable()
start end sta_id
2020-07-14 00:00:00 2020-09-16 18:00:00 1
2020-09-17 02:30:00 2020-09-17 17:30:00 2
2020-09-18 00:00:00 2020-09-18 20:00:00 3
2020-09-18 22:30:00 2020-09-19 20:30:00 4
2020-09-19 22:00:00 2020-09-20 00:30:00 5
2020-09-20 06:30:00 2020-09-21 18:00:00 6
2020-09-22 03:30:00 2020-09-22 18:00:00 7
2020-09-23 03:00:00 2020-09-23 18:30:00 8
2020-09-23 22:30:00 2020-09-25 17:30:00 9
2020-09-26 04:30:00 2020-09-26 20:30:00 10
2020-09-26 22:00:00 2020-10-05 18:00:00 11
2020-10-06 04:00:00 2020-10-06 18:00:00 12
2020-10-07 06:30:00 2020-10-07 18:00:00 13
2020-10-08 06:00:00 2020-10-08 19:00:00 14
2020-10-09 05:30:00 2020-10-09 18:00:00 15
2020-10-09 18:30:00 2020-10-10 02:00:00 16
2020-10-10 05:00:00 2020-10-10 22:30:00 17
2020-10-10 23:30:00 2021-04-01 18:30:00 18
2021-04-02 05:00:00 2021-04-02 18:30:00 19
2021-04-03 07:30:00 2021-04-03 18:30:00 20
2021-04-04 16:00:00 2021-04-04 20:30:00 21
2021-04-04 22:00:00 2021-04-05 00:00:00 22
2021-04-05 04:00:00 2021-04-06 19:00:00 23
2021-04-07 01:00:00 2021-04-07 05:00:00 24
2021-04-07 07:00:00 2021-04-21 18:00:00 25
2021-04-21 20:00:00 2021-04-24 18:30:00 26
2021-04-25 04:30:00 2021-04-25 08:00:00 27
2021-04-25 11:00:00 2021-04-25 13:30:00 28
2021-04-25 15:30:00 2021-04-25 20:00:00 29
2021-04-25 21:30:00 2021-04-30 18:30:00 30
2021-05-01 01:30:00 2021-05-02 19:30:00 31
2021-05-03 01:00:00 2021-05-27 23:30:00 32